/**
 * Created by xps-13 on 2017/1/5.
 */


import org.apache.http.impl.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.HttpEntity;
import org.apache.http.util.*;
import org.apache.http.client.HttpClient;
import org.apache.http.HttpResponse;




public class GetVideo {
    //获取json字符串的类
    //创建数据库对象
      Database db=new Database();
    //获取每个视频的信息
    public void getVideo() {
        try {
            db.getConnection();
            for(int i=0;i<34000;i++) {
                HttpClient httpClient = HttpClients.createDefault();
                HttpGet req = new HttpGet("http://api.bilibili.com/archive_rank/getarchiverankbypartion?callback=?&type=jsonp&tid=17" + "&pn="+i);
                req.addHeader("Accept", "application/json,text/javascript,*/*;q=0.01");
                req.addHeader("Accept-Encoding", "gzip,deflate,sdch");
                req.addHeader("Accept-Language", "zh-CN,zh;q=0.8");
                req.addHeader("Content-Type", "text/html;charset=utf-8");
                req.addHeader("User-Agent", "Mozilla/5.0(Windows NT 5.2) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/32.0.1700.76 SafarSafari/537.36");
                HttpResponse rep = httpClient.execute(req);
                HttpEntity repEntity = rep.getEntity();
                String content = EntityUtils.toString(repEntity);
                ReadJson p = new ReadJson();
                p.ReadJson(content);
            }
        } catch (Exception e) {

        }
    }

}

